home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
text
/
print
/
Stylus300_src.lha
/
Stylus300rev5.S
Wrap
Text File
|
1997-11-08
|
28KB
|
1,409 lines
*******
******* Epson Stylus300 printerdriver
*******
******* by Maurice van Wanum
*******
NeedLibs =0 ; 0/1 set to 1 if you need libs
incdir Include2.0:
*------ Included Files -----------------------------------------------
INCLUDE "exec/types.i"
include "exec/exec_lib.i"
INCLUDE "exec/nodes.i"
INCLUDE "exec/strings.i"
INCLUDE "devices/prtbase.i"
*------ Included Files -----------------------------------------------
INCLUDE "exec/lists.i"
INCLUDE "exec/memory.i"
INCLUDE "exec/ports.i"
INCLUDE "exec/libraries.i"
INCLUDE "devices/printer.i"
INCLUDE "devices/prtgfx.i"
_AbsExecBase equ 4
vmi_8lpi=360/8 Vertical-Motion-Index = 360 p.inch / 8 lpi = 45 / line
vmi_6lpi=360/6 60 per line
MOVEQ #-1,D0 ; show error for OpenLibrary()
RTS
DC.W 35 VERSION
DC.W 5 REVISION
_PEDData:
DC.L printerName
DC.L _Init
DC.L _Expunge
DC.L _Open
DC.L _Close
DC.B PPC_COLORGFX ; PrinterClass
DC.B PCC_YMCB ; ColorClass
DC.B 136 ; MaxColumns
DC.B 10 ; NumCharSets
DC.W 48 ; NumRows
DC.L 2880 ; MaxXDots
DC.L 3960 ; MaxYDots
DC.W 360 ; XDotsInch
DC.W 360 ; YDotsInch
DC.L _CommandTable ; Commands
DC.L _DoSpecial
DC.L _Render
DC.L 30 ; Timeout
DC.L _ExtendedCharTable ; 8BitChars
DC.L 0 ; PrintMode (reserve space)
DC.L 0 ; ptr to char conversion function
printerName:
DC.B "Stylus300",0
even
***** init.asm
**********************************************************************
_Init:
MOVE.L 4(A7),_PD
LEA _PEDData(PC),A0
MOVE.L A0,_PED
MOVE.L A6,-(A7)
MOVE.L [_AbsExecBase].w,A6
if NeedLibs
*------ open the dos library
LEA DLName(PC),A1
MOVEQ #0,D0
CALLEXE OpenLibrary
MOVE.L D0,_DOSBase
BEQ.s initDLErr
*------ open the graphics library
LEA GLName(PC),A1
MOVEQ #0,D0
CALLEXE OpenLibrary
MOVE.L D0,_GfxBase
BEQ.s initGLErr
*------ open the intuition library
LEA ILName(PC),A1
MOVEQ #0,D0
CALLEXE OpenLibrary
MOVE.L D0,_IntuitionBase
BEQ.s initILErr
endif
*------ maak de tabellen
moveq #78-1,d0
lea _CommandTable,a0
lea _CommandStrings,a1
bsr.s VulTab
moveq #96-1,d0
lea _ExtendedCharTable,a0
lea _ExtendedStrings,a1
bsr.s VulTab
*- einde
MOVEQ #0,D0
pdiRts:
MOVE.L (A7)+,A6
RTS
VulTab move.l a1,(a0)+
vt_ext tst.b (a1)+
bne.s vt_ext
dbra d0,VulTab
rts
if NeedLibs
initPAErr:
MOVE.L _IntuitionBase,A1
CALLEXE CloseLibrary
initILErr:
MOVE.L _GfxBase,A1
CALLEXE CloseLibrary
initGLErr:
MOVE.L _DOSBase,A1
CALLEXE CloseLibrary
initDLErr:
MOVEQ #-1,D0
BRA.S pdiRts
ILName: DC.B 'intuition.library',0
DLName: DC.B 'dos.library',0
GLName: DC.B 'graphics.library',0
endif
even
*---------------------------------------------------------------------
_Expunge:
if NeedLibs
MOVE.L _IntuitionBase,A1
LINKEXE CloseLibrary
MOVE.L _GfxBase,A1
CALLEXE CloseLibrary
MOVE.L _DOSBase,A1
CALLEXE CloseLibrary
endif
*---------------------------------------------------------------------
_Open:
MOVEQ #0,D0
RTS
*---------------------------------------------------------------------
_Close:
MOVEQ #0,D0
RTS
*** dospecial
** DoSpecial(command, outputBuffer, vline, currentVMI, crlfFlag, Parms)
** UWORD *command; $18
** char outputBuffer[]; $1c
** BYTE *vline; $20
** BYTE *currentVMI; $24
** BYTE *crlfFlag; $28
** UBYTE Parms[]; $2c
_DoSpecial
LB_7278 MOVEM.L D6/D7/A2/A3/A5,-(A7)
MOVE.L $0018(A7),A3 *command
MOVEQ #$00,D7 lengte van string
MOVEQ #$00,D6
MOVEQ #aRIN,D0
CMP.W (A3),D0
MOVE.L $001C(A7),A5 outbuff
MOVE.L $0020(A7),A2 *vline
BNE LB_732C
* init printer *
moveq #InitStringlen,d0 lengte
LEA InitString,A0 initstring
lea (a5,d7.l),a1
add.l d0,d7
subq #1,d0
LB_7294 MOVE.B (A0)+,(a1)+
dbf d0,LB_7294
MOVE.L _PD,A0 PD
CMP.W #LETTER,pd_Preferences+pf_PrintQuality(A0)
BNE.B LB_72BC
MOVEQ #$01,D0
MOVE.B D0,5(A5) LQ
LB_72BC MOVE.L $0024(A7),A0
MOVE.B #vmi_6lpi,(A0) currentVMI = 30
MOVE.L _PD,A0
CMP.W #EIGHT_LPI,pd_Preferences+pf_PrintSpacing(A0)
BNE.B LB_72E0
MOVE.B #'0',9(A5) 8LPI
MOVE.L $0024(A7),A0
MOVE.B #vmi_8lpi,(A0) currentVMI = 22
LB_72E0 MOVE.L _PD,A0 PD
MOVE.W pd_Preferences+pf_PrintPitch(A0),D0
CMP.W #ELITE,D0
BNE.B LB_72F8
Or.B #1,2(A5) elite
BRA.B LB_730A
LB_72F8 CMP.W #FINE,D0
BNE.B LB_730A
OR.B #4,2(A5)
LB_730A MOVE.L _PD,A1 PD
MOVE.W $0A5C(A1),D0 leftmargin
MOVE.L $002C(A7),A0 Parms[]
MOVE.B D0,(A0)
; MOVE.L _PD,A1 PD
MOVE.W $0A5E(A1),D0 rightmargin
MOVE.B D0,$0001(A0)
MOVEQ #aSLRM,D0
MOVE.W D0,(A3)
LB_732C MOVEQ #aCAM,D0
CMP.W (A3),D0
BNE.B LB_7388
* kantlijnen wissen *
MOVEQ #$30,D0
MOVE.L _PD,A0
CMP.W $0A68(A0),D0
BNE.B LB_7346
MOVEQ #$44,D0
ADD.L D0,D0
; CMPI.W #$7050,D0
dc.w $0c40
LB_7346 moveq #$50,d0
MOVE.L D0,D1
MOVE.W $0A56(A0),D0 printpitch
BNE.B LB_735A
MOVE.L D1,D0
ASL.L #2,D0
ADD.L D1,D0
ADD.L D0,D0
BRA.B LB_7370
LB_735A CMPI.W #$0400,D0
BNE.B LB_736A
MOVE.L D1,D0
ASL.L #2,D0
SUB.L D1,D0
ASL.L #2,D0
BRA.B LB_7370
LB_736A MOVE.L D1,D0
ASL.L #4,D0
ADD.L D1,D0
LB_7370 MOVEQ #$0A,D1
BSR.W LB_7B8C
MOVE.L $002C(A7),A0
MOVE.B D0,$0001(A0)
MOVEQ #$01,D0
MOVE.B D0,(A0)
MOVEQ #$00,D6
MOVEQ #$41,D1
MOVE.W D1,(A3)
LB_7388 MOVEQ #aSLRM,D0 zet marges
CMP.W (A3),D0
BNE.B LB_73DA
MOVE.L $002C(A7),A0 Parms
MOVE.B (A0),D0
BNE.B LB_73AA
CLR.B LB_3773
BRA.B LB_73B2
LB_73AA SUBQ.B #1,D0
MOVE.B D0,initmarge+2 Linkermarge
LB_73B2 MOVE.B $0001(A0),D0
MOVE.B D0,initmarge+5 rechtermarge
LB_73BC
lea (a5,d7.l),a1
LEA initmarge,A0 zetmargestring
MOVEQ #initmargelen,D0 lengte
add.l d0,d7
subq #1,d0
.1 move.b (a0)+,(a1)+
dbf d0,.1
MOVE.L D7,D0
BRA.W LB_7520 return(lengte)
LB_73DA MOVEQ #aPLU,D0
CMP.W (A3),D0
BNE.B LB_7406
* partial line up *
TST.B (A2) vline
BNE.B LB_73F0
MOVEQ #$01,D0
MOVE.B D0,(A2) vline=1
moveq #aSUS2,D0 command=bovenindex aan
move d0,(a3)
bra LB_751E
LB_73F0 MOVE.B (A2),D0
BPL.B LB_7400
MOVEQ #$00,D1
MOVE.B D1,(A2) vline=0
MOVEQ #aSUS3,D0 command=onderindex uit
MOVE.W D0,(A3)
BRA LB_751E
LB_7400 MOVEQ #-$01,D0 niet uitvoeren
BRA LB_7520
LB_7406 MOVEQ #aPLD,D0
CMP.W (A3),D0
BNE.B LB_7430
* partial line down *
TST.B (A2)
BNE.B LB_741C
MOVEQ #-$01,D0
MOVE.B D0,(A2) vline=-1
MOVEQ #aSUS4,D1
MOVE.W D1,(A3) command=subscript aan
BRA LB_751E
LB_741C MOVE.B (A2),D0
BLE.B LB_742A
CLR.B (A2)
MOVEQ #aSUS1,D0
MOVE.W D0,(A3) command=superscript uit
BRA LB_751E
LB_742A MOVEQ #-$01,D0 skippen
BRA.W LB_7520
LB_7430 MOVE.W (A3),D0
MOVEQ #aSUS0,D1 normaliseren
CMP.W D1,D0
BNE.B LB_743A
CLR.B (A2) vline=0
LB_743A MOVE.W (A3),D0
MOVEQ #aSUS1,D1
CMP.W D1,D0
BNE.B LB_7444
CLR.B (A2) vline=0
LB_7444 MOVE.W (A3),D0
MOVEQ #aSUS2,D1
CMP.W D1,D0
BNE.B LB_7450
MOVE.B #$01,(A2) vline=1
LB_7450 MOVE.W (A3),D0
MOVEQ #aSUS3,D1
CMP.W D1,D0
BNE.B LB_745A
CLR.B (A2) vline=0
LB_745A MOVE.W (A3),D0
MOVEQ #aSUS4,D1
CMP.W D1,D0
BNE.B LB_7464
ST (A2) vline=-1
LB_7464 MOVE.W (A3),D0
MOVEQ #aVERP0,D1
CMP.W D1,D0
MOVE.L $0024(A7),A0
BNE.B LB_7474
MOVEQ #vmi_8lpi,D1
MOVE.B D1,(A0) currentVMI=27
LB_7474 MOVE.W (A3),D0
MOVEQ #aVERP1,D1
CMP.W D1,D0
BNE.B LB_7480
MOVE.L $0024(A7),A0
MOVEQ #vmi_6lpi,D1
MOVE.B D1,(A0) currentVMI=36
LB_7480 MOVE.W (A3),D0
MOVEQ #aRI,D1
CMP.W D1,D0
BNE.B LB_74C0
* omgekeerde regelopschuiving *
MOVEQ #$1B,D1
MOVE.B D1,$00(A5,D7.L)
MOVE.B #'j',$01(A5,D7.L)
MOVE.B (A0),$02(A5,D7.L)
MOVE.L D7,D0
ADDQ.L #3,D0
BRA.W LB_7520
LB_74C0 MOVE.W (A3),D0
MOVEQ #aSFC,D1
CMP.W D1,D0
BNE.B LB_750E
* zet voorgrondkleur *
MOVE.L $002C(A7),A0
MOVEQ #39,D0
CMP.B (A0),D0
BNE.B LB_74D6
MOVEQ #30,D0
MOVE.B D0,(A0)
LB_74D6 MOVE.B (A0),D0
MOVEQ #37,D1
CMP.B D1,D0
BHI.W LB_751E
MOVEQ #$1B,D0
MOVE.B D0,$00(A5,D7.L)
MOVE.B #'r',$01(A5,D7.L)
MOVEQ #$00,D1
MOVE.B (A0),D1
LEA ISOColor-30,A0
MOVE.B $00(A0,D1.L),$02(A5,D7.L)
MOVE.L D7,D0
ADDQ.L #3,D0
BRA.W LB_7520
LB_750E
moveq #aSLPP,D0
CMP (a3),d0
bne ch_aSTBM
* zet papierlengte *
MOVE.L $002C(A7),A0 Parms
MOVE.B (A0),D0 lengte in regels = 1-127
BNE.s slpok1
moveq #1,d0
slpok1 bpl.s slpok2
moveq #127,d0
slpok2 lea (a5,d7.l),a1
move.b #27,(a1)+
move.b #'C',(a1)+
move.b d0,(a1)+
addq.l #3,d7
move.l d7,d0
BRA.W LB_7520 return(lengte)
ch_aSTBM
moveq #aSTBM,D0
CMP (A3),D0
BNE LB_751E
* zet onder en bovenmarges *
lea (a5,d7.l),a1
lea initTmarg,a0
addq.l #5,d7
moveq #5-1,d0
.1 move.b (a0)+,(a1)+
dbf d0,.1
moveq #0,d0
MOVE.L $002C(A7),A0 Parms
MOVE.B (A0),D0 regels van top
bne.s bovok
moveq #1,d0 1 is minimum
bovok MOVE.L $0024(A7),A0
moveq #0,d1
move.b (a0),d1 currentVMI
mulu d1,d0
move.b d0,(a1)+
rol.w #8,d0
move.b d0,(a1)+ bovenmarge
MOVE.L $002C(A7),A0 Parms
moveq #0,d0
MOVE.B 1(A0),D0 lengte in regels
bne.s ondok
move.l _PD,a0
move.w pd_Preferences+pf_PaperLength(a0),d0
ondok mulu d1,d0
move.b d0,(a1)+
rol.w #8,d0
move.b d0,(a1)+
addq #4,d7
move.l d7,d0
bra LB_7520
LB_751E MOVEQ #$00,D0
LB_7520 MOVEM.L (A7)+,D6/D7/A2/A3/A5
RTS
**** render
** ct
** x
** y
** status
_Render
LB_7528 SUBA.W #$000C,A7
MOVEM.L D2-D6/A2/A3/A5/A6,-(A7)
LEA $0038(A7),A6
MOVE.L (A6)+,D6 x
MOVE.L $0034(A7),D3 ct
MOVE.L (A6)+,D5 y
MOVE.L (A6)+,D0 status
CMPI.L #6,D0
BCC.W LB_7920 geen mogelijkheid ->
ADD.W D0,D0
add.W jtab(PC,D0.W),D0 springtabel
JMP jtab(PC,D0.W) spring
jtab dr.w MasterInit,SDEnR
dr.w DumpBuffer,ClearEnInit
dr.w CloseDown,PreMasterInit
**** MASTER INIT (case 0)
MasterInit
LB_755E MOVE.L D6,D0 x
mulu BytesPerRow,d0
MOVE.W D0,RowSize RowSize
ADDI.W #$0009,D0 +Numcommands
MOVE.W D0,ColorSize ColorSize
MOVEQ #$02,D1
MOVE.L _PD,A0
CMP.W $0A64(A0),D1 kleur ??
BNE.B LB_75C4 nee ->
MOVEQ #$04,D2 kleurenbuffers
MOVE.L D0,D3
ADD.W D3,D3
ADD.W D0,D3 ColorSize*3
MOVE.W D3,colors ;LB_37F8 colors[0] / black
CLR.W colors+2 ;LB_37FA colors[1] / Yellow
MOVE.W D0,colors+4 ;LB_37FC colors[2] / Magenta
MOVE.L D0,D3
ADD.W D3,D3
MOVE.W D3,colors+6 ;LB_37FE colors[3] /Cyan
MOVE.W D2,colorcodes ;LB_3800 colorcodes[0] / yellow
MOVEQ #$01,D3
MOVE.W D3,colorcodes+2 ;LB_3802 colorcodes[1] / magenta
MOVE.W D1,colorcodes+4 ;LB_3804 colorcodes[2] / cyan
CLR.W colorcodes+6 ;LB_3806 colorcodes[3] / black
BRA.B LB_75D2
LB_75C4 MOVEQ #$01,D2 Z/W
CLR.W colors ;LB_37F8 colors[0]=0
CLR.W colorcodes ;LB_3800 colorcodes[0]=0
LB_75D2 MOVE.W D2,NumColorBufs
MULU.W D2,D0 buffsize * numbufs
ADDQ.W #4,D0
MOVE.L D0,D2
ADD.W D2,D2 totalbuffsize = *2
MOVEQ #$00,D1
MOVE.W D2,D1
MOVE.W D0,BufSize ;LB_37F0 bufsize
MOVE.L D1,D0
MOVEQ #$01,D1
MOVE.L $0004.W,A6
JSR -$00C6(A6) AllocMem
MOVE.L _PD,A0
MOVE.L D0,$0060(A0) printbuff
MOVE.W D2,TotalBufSize ;LB_37F2 totalbuffsize
TST.L D0
BNE.B LB_7610
MOVEQ #$07,D5
BRA.W LB_7920 err=nomem
LB_7610 MOVE.W #$0008,dataoffset dataoffset
MOVE.B #'P',LB_37A1 10cpi
MOVE.B #$12,LB_37A2 condensed off
CLR.B LB_37A8 lmarge=0
MOVEQ #$30,D0
CMP.W $0A68(A0),D0 papersize
BNE.B LB_763C
MOVEQ #$44,D0
ADD.L D0,D0 136 koloms
dc.w $0c40
; CMPI.W #$7050,D0
LB_763C MOVEQ #$50,d0 80 koloms
MOVE.B D0,LB_37AB rmarge
MOVE.B #'1',LB_37AF uni-direc
MOVE.L $0064(A0),A0
PEA [Startbuflen].W
PEA Startbuf initstring
JSR (A0) write
ADDQ.W #8,A7
MOVE.L D0,D5 return(err)
BRA.W LB_7920
**** SCALE, DITHER EN RENDER (case 1)
SDEnR
LB_7664 MOVE.L _PD,A1
MOVE.L $0060(A1),A0 printbuf
MOVEQ #$00,D1
MOVE.W D5,D1 y
MOVEQ #$00,D0
MOVE.W dataoffset,D0
PEA colors ;LB_37F8
ADDA.L D0,A0
MOVE.L A0,-(A7) ptr
MOVE.L D1,-(A7) y
MOVE.L D3,-(A7) prtinfo
BSR.W _Transfer transfer
LEA $0010(A7),A7
MOVEQ #$00,D5 noerr
BRA.W LB_7920 return(d5)
**** DUMP BUFFER (case 2)
DumpBuffer
LB_7696 MOVE.L _PD,A1
MOVE.L $0060(A1),A5 printbuffer
MOVEQ #$00,D0
MOVE.W dataoffset,D0 offset
ADDA.L D0,A5
MOVE.L A5,A3
SUBQ.L #8,A3 ptr - numstartcmd
MOVEQ #$00,D6
MOVE.L A3,A0
MOVEQ #$00,D3
LEA colorcodes,A2 LB_3800
MOVE.L A0,$0028(A7)
BRA.W LB_77A6
LB_76C2 MOVE.L A5,A0
MOVEQ #$00,D4
MOVE.W RowSize,D4
ADDA.L D4,A0
*** haal nullen weg
subq #1,d4
.1 tst.b -(a0)
dbne d4,.1
LB_76E8
move.l a0,$2c(sp)
addq.w #1,d4
TST.L D4
BEQ.W LB_7786 lege regel ->
MOVE.L A5,A0
SUBQ.L #8,A0
LEA -$0007(A5),A1
LEA $002C(A7),A6
MOVE.L A1,(A6) zet ptr
MOVEQ #$1B,D0 ESC
MOVE.B D0,(A0)
MOVE.L (A6),A1
ADDQ.L #1,(A6)
MOVE.B #$72,(A1) 'r'
MOVE.L (A6)+,A1
LEA $002C(A7),A6
ADDQ.L #1,(A6)
MOVE.W (A2),D1
MOVE.B D1,(A1) zet kleurcode
MOVE.L (A6),A1
ADDQ.L #1,(A6)
MOVE.B D0,(A1) ESC
MOVE.L (A6)+,A1
LEA $002C(A7),A6
ADDQ.L #1,(A6)
MOVE.B #$2A,(A1) '*'
MOVE.L (A6),A1
ADDQ.L #1,(A6)
MOVE.W densitycode,D0 density-code
MOVE.B D0,(A1)
MOVE.L (A6)+,A1
ADDQ.L #1,$002C(A7)
MOVE.L D4,D0 xsize
moveq #0,d1
move.w BytesPerRow,d1
add.l d1,d0
subq.l #1,d0
BSR.W LB_7B8C delen door #bytes/row
MOVE.L D0,D1
MOVE.B D1,(A1) Lo-byte
MOVE.L $002C(A7),A1
ADDQ.L #1,$002C(A7)
ASR.L #8,D1
MOVE.B D1,(A1) Hi-byte
MOVE.L D0,D4
mulu BytesPerRow,d4
MOVE.B #$0D,$00(A5,D4.L) CR
MOVEQ #$09,D0
ADD.L D0,D4 +9
TST.L D6
BEQ.B LB_7784 geen transfer nodig
MOVE.L A0,$002C(A7)
LB_7774
move.l a3,a1
move.l d4,d0
move.l 4.w,a6
CALLEXEC CopyMem
LB_7784 ADDA.L D4,A3
LB_7786 MOVEQ #$00,D0
MOVE.W RowSize,D0
MOVEQ #$09,D1
ADD.L D1,D0 +9
CMP.L D0,D4
BEQ.B LB_7798
MOVEQ #$01,D6 transfer nodig
LB_7798 ADDQ.L #1,D3
MOVEQ #$00,D0
MOVE.W ColorSize,D0
ADDQ.L #2,A2
ADDA.L D0,A5
LB_77A6 MOVEQ #$00,D0
MOVE.W NumColorBufs,D0
CMP.L D0,D3
BLT.W LB_76C2
LEA (A3),A6
MOVE.B #$0D,(A6)+ CR
MOVE.B #$1B,(A6)+ ESC
MOVE.B #$4A,(A6)+ J
MOVE.L D5,D0
cmp #3,BytesPerRow
beq.s b3pr 3 bytes/row -> niet delen
tst d0
BPL.B LB_77C8
ADDQ.L #1,D0
LB_77C8
ASR.L #1,D0 ypos/2
b3pr MOVE.B D0,$0003(A3) opslaan
MOVE.L _PD,A1
MOVE.L $0064(A1),A0 pd_write
LEA $0004(A3),A1
MOVE.L A1,D0
SUB.L $0028(A7),D0 ptr2-ptr2start
MOVE.L D0,-(A7) omvang
MOVE.L $002C(A7),-(A7) ptr2start
JSR (A0) schrijf
ADDQ.W #8,A7
MOVE.L D0,D5 errorcode
BNE.W LB_7920
MOVEQ #$08,D0
CMP.W dataoffset,D0
BNE.B LB_7806
MOVEQ #$00,D0
MOVE.W BufSize,D0
DC.W $0C40
LB_7806 MOVEQ #0,D0
ADDQ.L #8,D0
MOVE.W D0,dataoffset
BRA.W LB_7920
**** CLEAR EN INIT (case 3)
ClearEnInit
LB_7814 MOVE.L _PD,A1
MOVE.L $0060(A1),A0
MOVEQ #$00,D0
MOVE.W dataoffset,D0
ADDA.L D0,A0
MOVE.L A0,$002C(A7)
MOVEQ #$00,D0
MOVE.W BufSize,D0
MOVEQ #$0D,D1
SUB.L D1,D0
LB_7838 MOVE.L $002C(A7),A0
ADDQ.L #1,$002C(A7)
CLR.B (A0)
SUBQ.L #1,D0
BNE.B LB_7838
MOVEQ #$00,D5
BRA.W LB_7920
**** CLOSE DOWN (case 4)
CloseDown
LB_784C MOVEQ #$00,D5
MOVE.L D3,D0
SUBQ.L #1,D0
BEQ.B LB_78D0
MOVE.L _PD,A0
MOVE.W $0A56(A0),D0
CMPI.W #ELITE,D0
BNE.B LB_786E
MOVE.B #'M',LB_37A1
BRA.B LB_787C
LB_786E CMPI.W #FINE,D0
BNE.B LB_787C
MOVE.B #$0F,LB_37A2
LB_787C MOVEQ #$00,D0
MOVE.W $0A5C(A0),D0
SUBQ.L #1,D0
MOVE.B D0,LB_37A8
MOVE.W $0A5E(A0),D0
MOVE.B D0,LB_37AB
MOVE.B #$30,LB_37AF
MOVE.L $0064(A0),A0
PEA [Startbuflen].W
PEA Startbuf
JSR (A0)
MOVE.L D0,D5
BTST #$0B,D6
ADDQ.W #8,A7
BNE.B LB_78D0
MOVE.L _PD,A1
MOVE.L $0064(A1),A0
PEA 1.W
PEA formfeed
JSR (A0)
ADDQ.W #8,A7
MOVE.L D0,D5
LB_78D0 MOVE.L _PD,A1
MOVE.L $0068(A1),A0
JSR (A0)
MOVE.L _PD,A0
MOVE.L $0060(A0),D0
BEQ.B LB_7920
MOVEQ #$00,D1
MOVE.W TotalBufSize,D1
MOVE.L D0,A1
MOVE.L D1,D0
MOVE.L $0004.W,A6
JSR -$00D2(A6)
BRA.B LB_7920
**** PRE-MASTER INIT (case 5)
PreMasterInit
LB_78FE
ANDI.L #$00000700,D6
MOVE.L D6,-(A7)
BSR.W LB_7B24 density.c
ADDQ.W #4,A7
MOVEQ #$00,D5 Err=noerr
MOVE.W D0,densitycode Density
move.l _PED,a0
move BytesPerRow,d0
asl.w #3,d0
move d0,ped_NumRows(a0)
LB_7920 MOVE.L D5,D0 return err
MOVEM.L (A7)+,D2-D6/A2/A3/A5/A6
ADDA.W #$000C,A7
RTS
_Transfer:
; Transfer(PInfo, y, ptr, colors)
; struct PrtInfo *PInfo 4-7
; UWORD y; 8-11
; UBYTE *ptr; 12-15
; UWORD *colors; 16-19
;
movem.l d2-d6/a2-a4,-(sp) ;save regs used
movea.l 36(sp),a0 ;a0 = PInfo
move.l 40(sp),d0 ;d0 = y
movea.l 44(sp),a1 ;a1 = ptr
movea.l 48(sp),a2 ;a2 = colors
moveq.l #3,d2
and.w d0,d2 ;d2 = y & 3
lsl.w #2,d2 ;d2 = (y & 3) << 2
movea.l pi_dmatrix(a0),a3 ;a3 = dmatrix
adda.l d2,a3 ;a3 = dmatrix + ((y & 3) << 2)
movea.l _PED,a4 ;a4 = ptr to PED
divu.w ped_NumRows(a4),d0 ;d0 = y / NumRows
swap.w d0 ;d0 = y % NumRows
move.w d0,d6
not.b d6 ;d6 = bit to set
asr.w #3,d0 ;d0 = ymod / 8
adda.w d0,a1 ;ptr += ymod / 8
movea.l _PD,a4 ;a4 = ptr to PD
cmpi.w #SHADE_COLOR,pd_Preferences+pf_PrintShade(a4) ;color dump?
bne not_color ;no
color:
; a0 - PInfo
; a1 - ptr
; a2 - colors
; a3 - dmatrix ptr
; d0 - y
; d6 - bit to set
*** NOTE : This section is _NOT_ tested (MVW)
movem.l d7/a5-a6,-(sp) ;save regs used
** Set #bytes/kolom on stack (MVW)
move.l _PED,a4
move.w BytesPerRow,d0 ;d0 = numrows/8
move d0,-(SP)
movea.l a1,a4
movea.l a1,a5
movea.l a1,a6
adda.w (a2)+,a1 ;a1 = ptr + colors[0] (bptr)
adda.w (a2)+,a4 ;a4 = ptr + colors[1] (yptr)
adda.w (a2)+,a5 ;a5 = ptr + colors[2] (mptr)
adda.w (a2)+,a6 ;a6 = ptr + colors[3] (cptr)
movea.l pi_ColorInt(a0),a2 ;a2 = ColorInt ptr
move.w pi_width(a0),width ;# of pixels to do
move.w pi_xpos(a0),d2 ;d2 = x
movea.l pi_ScaleX(a0),a0 ;a0 = ScaleX (sxptr)
mulu d2,d0 ;d0 = x * #bytes/kolom (MVW)
move.w d6,d7 ;d7 = bit to set
; a0 - sxptr
; a1 - bptr
; a2 - ColorInt ptr
; a3 - dmatrix ptr
; a4 - yptr
; a5 - mptr
; a6 - cptr
; d0 - byte to set (x3 (x * 3))
; d1 - Black
; d2 - x
; d3 - dvalue (dmatrix[x & 3])
; d4 - Yellow
; d5 - Magenta
; d6 - Cyan
; d7 - bit to set
cwidth_loop:
move.b PCMBLACK(a2),d1 ;d1 = Black
move.b PCMYELLOW(a2),d4 ;d4 = Yellow
move.b PCMMAGENTA(a2),d5 ;d5 = Magenta
move.b PCMCYAN(a2),d6 ;d6 = Cyan
addq.l #ce_SIZEOF,a2 ;advance to next entry
move.w (a0)+,sx ;# of times to use this pixel
csx_loop:
moveq.l #3,d3
and.w d2,d3 ;d3 = x & 3
move.b 0(a3,d3.w),d3 ;d3 = dmatrix[x & 3]
black:
cmp.b d3,d1 ;render black?
ble.s yellow ;no, try ymc
bset.b d7,0(a1,d0.w) ;set black pixel
bra.s csx_end
yellow:
cmp.b d3,d4 ;render yellow pixel?
ble.s magenta ;no.
bset.b d7,0(a4,d0.w) ;set yellow pixel
magenta:
cmp.b d3,d5 ;render magenta pixel?
ble.s cyan ;no.
bset.b d7,0(a5,d0.w) ;set magenta pixel
cyan:
cmp.b d3,d6 ;render cyan pixel?
ble.s csx_end ;no, skip to next pixel.
bset.b d7,0(a6,d0.w) ;clear cyan pixel
csx_end
addq.w #1,d2 ;x++
add.w (SP),d0 ;x3 += #bytes/kolom (MVW)
subq.w #1,sx ;sx--
bne.s csx_loop
subq.w #1,width ;width--
bne.s cwidth_loop
** correct stack (MVW)
addq.l #2,SP
movem.l (sp)+,d7/a5-a6 ;restore regs used
bra exit
not_color:
; a0 - PInfo
; a1 - ptr
; a2 - colors
; a3 - dmatrix ptr
; d0 - y (scratched : d0 = #bytes/kolom (MVW))
; d6 - bit to set
** # bytes/kolom (MVW)
move.l _PED,a4
moveq #0,d0
move BytesPerRow,d0 ;d0 = #bytes/kolom (MVW)
adda.w (a2),a1 ;a1 = ptr + colors[0]
move.w pi_width(a0),d1 ;d1 = width
subq.w #1,d1 ;adjust for dbra
move.w pi_threshold(a0),d3 ;d3 = threshold, thresholding?
beq.s grey_scale ;no, grey-scaling
threshold:
; a0 - PInfo
; a1 - ptr
; a3 - dmatrix ptr
; d1 - width-1
; d3 - threshold
; d6 - bit to set
eori.b #15,d3 ;d3 = dvalue
movea.l pi_ColorInt(a0),a2 ;a2 = ColorInt ptr
move.w pi_xpos(a0),d2 ;d2 = x
movea.l pi_ScaleX(a0),a0 ;a0 = ScaleX (sxptr)
mulu d0,d2
adda.l d2,a1 ;ptr += x * #bytes/kolom (MVW)
; a0 - sxptr
; a1 - ptr
; a2 - ColorInt ptr
; a3 - dmatrix ptr (NOT USED)
; d1 - width - 1
; d3 - dvalue
; d4 - Black
; d5 - sx
; d6 - bit to set
twidth_loop:
move.b PCMBLACK(a2),d4 ;d4 = Black
addq.l #ce_SIZEOF,a2 ;advance to next entry
move.w (a0)+,d5 ;d5 = # of times to use this pixel
cmp.b d3,d4 ;render this pixel?
ble.s tsx_end ;no, skip to next pixel.
subq.w #1,d5 ;adjust for dbra
tsx_render: ;yes, render this pixel sx times
bset.b d6,(a1) ;*(ptr) |= bit;
adda.l d0,a1 ;ptr += #bytes/kolom (MVW)
dbra d5,tsx_render ;sx--
dbra d1,twidth_loop ;width--
bra.s exit ;all done
tsx_end:
mulu d0,d5
adda.l d5,a1 ;ptr += sx * #bytes/kolom (MVW)
dbra d1,twidth_loop ;width--
bra.s exit
grey_scale:
; a0 - PInfo
; a1 - ptr
; a3 - dmatrix ptr
************; d0 - y
; d1 - width-1
; d6 - bit to set
movea.l pi_ColorInt(a0),a2 ;a2 = ColorInt ptr
move.w pi_xpos(a0),d2 ;d2 = x
movea.l pi_ScaleX(a0),a0 ;a0 = ScaleX (sxptr)
mulu d0,d2
adda.l d2,a1 ;ptr += x * #bytes/kolom (MVW)
; a0 - sxptr
; a1 - ptr
; a2 - ColorInt ptr
; a3 - dmatrix ptr
; d1 - width
; d2 - x
; d3 - dvalue (dmatrix[x & 3])
; d4 - Black
; d5 - sx
; d6 - bit to set
gwidth_loop:
move.b PCMBLACK(a2),d4 ;d4 = Black
addq.l #ce_SIZEOF,a2 ;advance to next entry
move.w (a0)+,d5 ;d5 = # of times to use this pixel
subq.w #1,d5 ;adjust for dbra
gsx_loop:
moveq.l #3,d3
and.w d2,d3 ;d3 = x & 3
move.b 0(a3,d3.w),d3 ;d3 = dmatrix[x & 3]
cmp.b d3,d4 ;render this pixel?
ble.s gsx_end ;no, skip to next pixel.
bset.b d6,(a1) ;*ptr |= bit
gsx_end
adda.l d0,a1 ;ptr += #bytes/kolom
addq.w #1,d2 ;x++
dbra d5,gsx_loop ;sx--
dbra d1,gwidth_loop ;width--
exit:
movem.l (sp)+,d2-d6/a2-a4 ;restore regs used
moveq.l #0,d0 ;flag all ok
rts ;goodbye
sx dc.w 0
width dc.w 0
_Density
LB_7B24 SUBQ.W #8,A7
MOVEQ #$30,D0
MOVE.L _PD,A0
CMP.W $0A68(A0),D0 papersize
BNE.B LB_7B3A
MOVEQ #$44,D0
ADD.L D0,D0 136 kolommen
DC.W $0C40
; CMPI.W #$7050,D0
LB_7B3A MOVEQ #$50,D0 80 kolommen
MOVE.L _PED,A0
MOVE.B D0,$0016(A0) max.kolommen
MOVE.L $000C(A7),D0
LSR.L #8,D0 door 256
MOVE.L D0,$0004(A7) density opslaan
MOVE.L D0,D1
add.l d1,d1
lea YDPI,A1
move.w 0(A1,d1.l),ped_YDotsInch(a0)
lea BytesTab,a1
move.w 0(a1,d1.l),BytesPerRow
LEA XDPI,A1 XDPI
ADDA.L D1,A1
MOVE.w (A1),$0022(A0) XDPI
MOVEQ #$00,D1
MOVE.B $0016(A0),D1 max.kolommen
MOVE.w (A1),D0 XDPI
mulu d1,d0 XDPI * #kolommen
MOVEQ #$0A,D1
BSR.W LB_7B8C door 10
MOVE.L D0,$001A(A0) MaxXdots
move.w ped_YDotsInch(a0),d0 YDPI
mulu #11,d0 YDPI * inches/pagina
move.l d0,ped_MaxYDots(a0) MaxYdots
MOVE.L $0004(A7),D0
LEA LB_37E4,A0
MOVE.B $00(A0,D0.L),D0 Densitycode
ADDQ.W #8,A7
RTS
*** divu.l
LB_7B8C TST.L D0
BPL.W LB_7BAE
NEG.L D0
TST.L D1
BPL.W LB_7BA4
NEG.L D1
BSR.W LB_7BBE
NEG.L D1
RTS
LB_7BA4 BSR.W LB_7BBE
NEG.L D0
NEG.L D1
RTS
LB_7BAE TST.L D1
BPL.W LB_7BBE
NEG.L D1
BSR.W LB_7BBE
NEG.L D0
RTS
LB_7BBE MOVE.L D2,-(A7)
SWAP D1
MOVE.W D1,D2
BNE.W LB_7BE8
SWAP D0
SWAP D1
SWAP D2
MOVE.W D0,D2
BEQ.W LB_7BD8
DIVU.W D1,D2
MOVE.W D2,D0
LB_7BD8 SWAP D0
MOVE.W D0,D2
DIVU.W D1,D2
MOVE.W D2,D0
SWAP D2
MOVE.W D2,D1
MOVE.L (A7)+,D2
RTS
LB_7BE8 MOVE.L D3,-(A7)
MOVEQ #$10,D3
CMPI.W #$0080,D1
BCC.W LB_7BF8
ROL.L #8,D1
SUBQ.W #8,D3
LB_7BF8 CMPI.W #$0800,D1
BCC.W LB_7C04
ROL.L #4,D1
SUBQ.W #4,D3
LB_7C04 CMPI.W #$2000,D1
BCC.W LB_7C10
ROL.L #2,D1
SUBQ.W #2,D3
LB_7C10 TST.W D1
BMI.W LB_7C1A
ROL.L #1,D1
SUBQ.W #1,D3
LB_7C1A MOVE.W D0,D2
LSR.L D3,D0
SWAP D2
CLR.W D2
LSR.L D3,D2
SWAP D3
DIVU.W D1,D0
MOVE.W D0,D3
MOVE.W D2,D0
MOVE.W D3,D2
SWAP D1
MULU.W D1,D2
SUB.L D2,D0
BCC.W LB_7C3C
SUBQ.W #1,D3
ADD.L D1,D0
LB_7C3C MOVEQ #$00,D1
MOVE.W D3,D1
SWAP D3
ROL.L D3,D0
SWAP D0
EXG D0,D1
MOVE.L (A7)+,D3
MOVE.L (A7)+,D2
RTS
LB_7c41 dc.w 0
*** mulu.l
LB_7C50 MOVEM.L D2/D3,-(A7)
MOVE.L D0,D2
MOVE.L D1,D3
SWAP D2
SWAP D3
MULU.W D1,D2
MULU.W D0,D3
MULU.W D1,D0
ADD.W D3,D2
SWAP D2
CLR.W D2
ADD.L D2,D0
MOVEM.L (A7)+,D2/D3
RTS
**********************************************************************
SECTION printerbss,BSS
_PD Ds.L 1
_PED Ds.L 1
if NeedLibs
_DOSBase Ds.L 1
_GfxBase Ds.L 1
_IntuitionBase Ds.L 1
endif
SECTION printerdata,DATA
_CommandStrings
LB_32D0 DC.B $1B,'@',$00 aRIS
LB_32D6 DC.B $FF,$00 aRIN
DC.B $0A,$00 aIND
DC.B $0D,$0A,$00 aNEL (CR LF)
DC.B $FF,$00 aRI (reverse LF)
DC.B $1B,'5',$1B,'-',$FE,$1B,'F',$1B,'H',0 aSGR normale tekenset
dc.b $1B,'4',$00 cursief aan
dc.b $1B,'5',0 - uit
DC.B $1B,'-',$01,$00 onderlijnd aan
dc.b $1B,'-',$FE,$00 - uit
dc.b $1B,'E',$00 vet aan
dc.b $1B,'F',0 - uit
DC.B $FF,$00,$FF,$00 voorgrond/achtergrond-kleur
dc.b $1B,'P' normale grootte
DC.B $12,$1B,'W',$FE,$00
dc.b $1B,'M' elite aan
DC.B $12,$1B,'W',$FE,$00
dc.b $1B,'P',0 - uit
DC.B $0F,$1B,$50,$1B,$57,$FE,0 verkleind aan
DC.B $12,$00 - uit
dc.b $1B,'W',1,0 vergroot aan
DC.B $1B,'W',$FE,0 - uit
dc.b $1B,'q',2,0 schaduw aan
DC.B $1B,'q',$FE,0 - uit
dc.b $1B,'G',0 dubbeldik aan
DC.B $1B,'H',0 - uit
dc.b $1B,'x',1,0 NLQ aan
DC.B $1B,'x',$FE,0 Draft
dc.b $1B,'S',$FE,0 superscript aan
DC.B $1B,'T',0 - uit
dc.b $1B,'S',1,0 subscript aan
DC.B $1B,'T',0 - uit
dc.b $1B,'T',0 normaliseer regel
DC.B $FF,$00,$FF,$00 PLU/PLD
dc.b $1B,'R',$FE,$00
DC.B $1B,'R',$01,$00,$1B,'R',$02,$00
DC.B $1B,'R',$03,$00,$1B,'R',$04,$00
DC.B $1B,'R',$05,$00,$1B,'R',$06,$00
DC.B $1B,'R',$07,$00,$1B,'R',$08,$00
DC.B $1B,'R',$09,$00,$1B,'R',$0A,$00
DC.B $1B,'p','1',0 prop aan
dc.b $1B,'p','0',0 - uit
DC.B $FF,$00 - wissen
dc.b $FF,$00,$FF,$00,$FF,$00 automatisch uitlijnen
DC.B $FF,$00,$FF,$00,$FF,$00,$FF,$00 (niet ondersteund)
DC.B $1B,'0',0 8lpi
dc.b $1B,'2',0 6lpi
DC.B $ff,0 aSLPP lengte pagina in regels
dc.b $1B,'N',0 perforatie skip (obsolete)
DC.B $1B,'O',0 - uit
dc.b $FF,$00,$FF,$00 linker/rechter-kantlijn
DC.B $FF,$00,$FF,$00 boven/onder-kantlijn
dc.b $FF,$00,$FF,$00 onder/boven+linker/rechter-kl
DC.B $FF,$00 kantlijnen wissen
dc.b $FF,$00,$FF,$00 stel hori/verti-tab in
dc.b $FF,$00 horitab wissen
DC.B $1B,'D',$FE,0 wis alle hori-tabs
dc.b $FF,$00 vertitab wissen
dc.b $1B,'B',$fe,0 alle verti-tab wissen
DC.B $1B,'D',$FE,$1B,'B',$FE,0 alle tabs wissen
DC.B $1B,'D',$08,$10,$18,$20 stel standaard hori-tabs in
DC.B $28,$30,$38,$40,$48,$50,$58,$FE,0
DC.B $FF,$00,$FF,$00 extend/raw
_ExtendedStrings
LB_3522 DC.B $20,$00,$AD,$00,$BD,$00
DC.B $9C,$00,$CF,$00,$BE,$00,$DD,$00
DC.B $F5,$00,$F9,$00,$B8,$00,$A6,$00,$AE,$00
DC.B $AA,$00,$F0,$00,$A9,$00,$EE,$00
DC.B $F8,$00,$F1,$00,$fd,$00,$FC,$00
DC.B $EF,$00,$E6,$00,$F4,$00,$FA,$00
DC.B $F7,$00,$FB,$00,$A7,0
DC.B $AF,$00,$AC,$00
DC.B $AB,$00,$F3,$00,$A8,$00,$B7,$00
DC.B $B5,$00,$B6,$00,$C7,$00,$8E,$00
DC.B $8F,$00,$92,$00,$80,$00,$D4,$00
DC.B $90,$00,$D2,$00,$D3,$00,$DE,$00
DC.B $D6,$00,$D7,$00,$D8,$00,$D1,$00
DC.B $A5,$00,$E3,$00,$E0,$00,$E2,$00
DC.B $E5,$00,$99,$00,$9E,$00,$9D,$00
DC.B $EB,$00,$E9,$00,$EA,$00,$9A,$00
DC.B $ED,$00,$E8,$00,$E1,$00,$85,$00
DC.B $A0,$00,$83,$00,$C6,$00,$84,$00
DC.B $86,$00,$91,$00,$87,$00,$8A,$00
DC.B $82,$00,$88,$00,$89,$00,$8D,$00
DC.B $A1,$00,$8C,$00,$8B,$00,$D0,$00
DC.B $A4,$00,$95,$00,$A2,$00,$93,$00
DC.B $E4,$00,$94,$00,$F6,$00,$9B,$00
DC.B $97,$00,$A3,$00,$96,$00,$81,$00
DC.B $EC,$00,$E7,$00,$98,$00
even
** marge zetten
initmarge
DC.B $1B,'l'
LB_3773 dc.b 'L',$1B,'Q'
LB_3776 dc.b 'R'
initmargelen=*-initmarge
InitString
dc.b $1B,'!',0 10 cpi/normaal
dc.b $1b,'x',0 draft
DC.B $1B,$54 super/sub-script uit
DC.B $1B,'2',$0D 6lpi, CR
InitStringlen=*-InitString
** onder/boven-marges
initTmarg dc.b 27,'(c',4,0
ISOColor dc.b $00,$05,$06,$04
DC.B $03,$01,$02,$00
** initprinter voor grafiek en terug naar tekst
Startbuf
DC.B $1B
LB_37A1 dc.b 'P'
LB_37A2 dc.b $12,$1B,'W',$00,$1B,'l'
LB_37A8 DC.B 'L',$1B,'Q'
LB_37AB dc.b 'R',$0D,$1B,'U'
LB_37AF dc.b '1'
Startbuflen=*-Startbuf
formfeed DC.B $0C
even
XDPI DC.w 90,90 XDPI
dc.w 120
dc.w 180
dc.w 360
dc.w 180
dc.w 360
DC.w 360
YDPI dc.w 180,180
dc.w 180
dc.w 180
dc.w 180
dc.w 360
dc.w 360
dc.w 360
LB_37E4 DC.B '&','&','!',"'" densitycodes
DC.B '(','G','H','I'
BytesTab dc.w 3,3,3,3
dc.w 3,6,6,6
section printerbss,BSS
RowSize ds.w 1
ColorSize ds.w 1
BufSize ds.w 1
TotalBufSize ds.w 1
dataoffset ds.w 1
densitycode ds.w 1
colors ; 4 ints
LB_37F8 Ds.w 1
LB_37FA ds.w 1
LB_37FC ds.w 1
LB_37FE ds.w 1
colorcodes ; 4 ints
LB_3800 Ds.w 1
LB_3802 ds.w 1
LB_3804 ds.w 1
LB_3806 ds.w 1
NumColorBufs Ds.w 1
BytesPerRow ds.w 1
_CommandTable ds.l 78
_ExtendedCharTable ds.l 96
END